
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;

public class Item extends Thread{
	private int posX;
	private int posY;
	private int point;
	private String type;
	private Image pic;
	private boolean alive;
	
	public Item(int x, int y){
		posX=x;
		posY=y;
		alive=true;
		type = "normal";
	}
	public void setType(String type, int pnt){
		this.type = type;
		point = pnt;
		if(type.equals("apple"))
			pic=Images.Grass;
		if(type.equals("banana"))
			pic=Images.Hat;
	}
	public void setType(String type){
		this.type = type;
		if(type.equals("wall"))
			pic=Images.BWall;

	}
	public String getType(){
		return type;
	}
	public void setPoint(int pt){
		point = pt;
	}
	public int getPosX(){
		return posX;
	}
	public int getPosY(){
		return posY;
	}
	public int getPoint(){
		return point;
	}
	public boolean is_Alive(){
		return alive;
	}
	public void destroy(){
		alive=false;
	}
	public void draw(PlayScreen scr){
		if(is_Alive()){
			Graphics g = scr.getGraphics();
			int px = getPosX()*PlayScreen.BLOCK_W+PlayScreen.OFFSET_X;
			int py = getPosY()*PlayScreen.BLOCK_H+PlayScreen.OFFSET_Y;
			int pw = PlayScreen.BLOCK_W;
			int ph = PlayScreen.BLOCK_H;
			//if(type.equals("normal")){
				//g.setColor(new Color(100,100,0));
				//g.fillOval(px+10,py+10,pw-25,ph-25);
			//}else
			if(type.equals("wall")){
				g.drawImage(pic,px,py,pw,ph,scr);
			}else{ 
				g.drawImage(pic,px+10,py+10,pw-20,ph-20,scr);
			}
		}
	}
}
